﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using mock_ehr_lib.Model;

namespace mock_ehr_lib.View.MainTabs
{
    public partial class PatientInfo : UserControl
    {
        public PatientInfo()
        {
            InitializeComponent();
            if (DesignMode) return;
            Load += patientInfoLoad;
            MockEHRApplication.Instance.OnPatientChanged += onPatientChanged;
        }

        void patientInfoLoad(object sender, EventArgs e)
        {
            var currentPatient = MockEHRApplication.Instance.CurrentPatient;
            if (currentPatient == null) return;
            lblName.Text = "Name: " + currentPatient.Summary.GivenName + " " + currentPatient.Summary.FamilyName;
            lblDOB.Text = "DOB: " + (currentPatient.Summary.DOB.HasValue ? currentPatient.Summary.DOB.Value.ToString("MM/dd/yyyy") : "NA");
        }

        void onPatientChanged(Patient newPatient)
        {
            patientInfoLoad(this, null);
        }
    }
}
